{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/linked-list-components\n",
    "\n",
    "\n",
    "Runtime: 116 ms, faster than 43.10% of Python3 online submissions for Linked List Components.\n",
    "Memory Usage: 18.9 MB, less than 33.18% of Python3 online submissions for Linked List Components.\n",
    "\n",
    "\n",
    "```python\n",
    "class Solution:\n",
    "    def numComponents(self, head: ListNode, G: List[int]) -> int:\n",
    "        subSet = set(G)\n",
    "        components = [[]]\n",
    "        node = head\n",
    "        while node:\n",
    "            val = node.val\n",
    "            if val in subSet:\n",
    "                components[-1].append(val)\n",
    "            else:\n",
    "                components.append([])\n",
    "            node = node.next\n",
    "        counting = 0\n",
    "        for c in components:\n",
    "            if len(c) != 0:\n",
    "                counting += 1\n",
    "        return counting\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
